 <% excursions = subject_excursions(profile_or_current_subject, {:scope => scope, :limit => 0, :page=> page, :sort_by=> params[:sort_by]||sort_by||"popularity"}) 
 %>
  
  <% excursions.each do |excursion| %>
    <%= render :partial => 'excursions/excursion', :locals => { :excursion => excursion } %>
  <% end %> 

<script>
	$(document).ready(function(){		
		<%- if controller_name == 'excursions' && page != 0%>
			$('#excursions_tab_ready ul').pageless({ 
                          totalPages: <%=excursions.num_pages%>,
                          url: window.location.href,
                          currentPage: <%=excursions.current_page%>,
                          loader: '.loader_pagination',
                          end: function(){
                            $('.loader_pagination').hide();
                          }
      		});
		<%elsif controller_name == "users" %>
			update_pageless_state("excursions", <%=excursions.num_pages%>, <%=excursions.current_page%>);

			re_apply_pageless("excursions");
		<%end%>
		
		$("footer#footer").addClass("fixed-bottom");
    $("#wrap").removeClass("wrap-when-fixed-bottom"); 
	});
	
	function add_excursions_backstrech(){		
      if(typeof backstrech_items != "undefined"){
        <% excursions.each do |excursion| %>    	  
              backstrech_items.excursions["#excursion-<%=excursion.id%>"] = "<%=excursion_raw_thumbail(excursion)%>";
        <% end %> 
  		}
	}

	add_excursions_backstrech();
</script>

